<template>
	<view>
		<view class="titlebar-class">
			<text class="cancel-confirm" :style="{color: color}" @click="onCancel">{{ cancelText }}</text>
			<text class="title">{{ title }}</text>
			<text class="cancel-confirm" :style="{color: color}" @click="onConfirm">{{ confirmText }}</text>
		</view>
		<view>
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			color: {
				type: String,
				default: '#333333'
			},
			title: {
				type: String,
				default: ''
			},
			confirmText: {
				type: String,
				default: '确定'
			},
			cancelText: {
				type: String,
				default: '取消'
			}
		},
		data() {
			return {

			};
		},
		methods: {
			onConfirm() {
				this.$emit("confirm")
			},
			onCancel() {
				this.$emit("cancel")
			}
		}
	}
</script>

<style lang="scss">
	.titlebar-class {
		display: flex;
		justify-content: space-between;
		height: 44px;
		line-height: 44px;
		border-bottom: 1px solid #f8f8f8;

		text {
			padding: 0 16px;
		}

		.title {
			max-width: 50%;
			text-align: center;
			font-weight: 500;
			font-size: 16px;
		}

		.cancel-confirm {
			padding: 0 16px;
			font-size: 14px;
			color: #1989fa;

			&:hover {
				background-color: #f2f3f5;
			}
		}
	}
</style>
